In [10]:
import pickle
from sklearn import manifold
import numpy as np

from plotly.offline import download_plotlyjs, init_notebook_mode, iplot, iplot_mpl
from plotly.graph_objs import *
init_notebook_mode()
In [46]:
layout = Layout(
    autosize=False,
    width=600,
    height=600,
    xaxis=dict(
        autorange=True,
        showgrid=False,
        zeroline=False,
        autotick=True,
        showline=True,
        mirror='all'
    ),
    yaxis=dict(
        autorange=True,
        showgrid=False,
        zeroline=False,
        autotick=True,
        showline=True,
        mirror='all'
    )
)
In [2]:
with open("models.pickle", 'rb') as f:
    models = pickle.load(f)
Using Theano backend.
Using gpu device 0: GeForce GTX 980 (CNMeM is disabled)
In [3]:
model = models[0].model
weights = model.layers[0].get_weights()
store_embedding = weights[0]
dow_embedding = weights[1]
year_embedding = weights[4]
month_embedding = weights[5]
day_embedding = weights[6]
german_states_embedding = weights[20]
woy_embedding = weights[21]
weather_event_embedding = weights[30]
In [56]:
tsne = manifold.TSNE(init='pca', random_state=0, method='exact')
Y = tsne.fit_transform(german_states_embedding)
names = ['Niedersachsen', 'Hamburg', 'Thueringen', 'RheinlandPfalz', 'SachsenAnhalt', 'BadenWuerttemberg','Sachsen', 'Berlin', 'Hessen', 'SchleswigHolstein', 'Bayern', 'NordrheinWestfalen']
trace1 = Scatter(
    x=-Y[:, 0],
    y=-Y[:, 1],
    mode='markers+text',
    text=names,
    textposition='top'
)
fig = Figure(data=[trace1], layout=layout)
iplot(fig)
In [55]:
tsne = manifold.TSNE(init='pca', random_state=0, method='exact')
Y = tsne.fit_transform(dow_embedding)
names = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat','Sun']
trace1 = Scatter(
    x=-Y[:, 0],
    y=-Y[:, 1],
    mode='markers+text',
    text=names,
    textposition='top'
)
fig = Figure(data=[trace1], layout=layout)
iplot(fig)
In [57]:
tsne = manifold.TSNE(init='pca', random_state=0, method='exact')
Y = tsne.fit_transform(month_embedding)
names = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
trace1 = Scatter(
    x=-Y[:, 0],
    y=-Y[:, 1],
    mode='markers+text',
    text=names,
    textposition='top'
)
fig = Figure(data=[trace1], layout=layout)
iplot(fig)
In [63]:
tsne = manifold.TSNE(init='pca', random_state=0, method='exact', learning_rate=500, verbose=0, early_exaggeration=1)
Y = tsne.fit_transform(store_embedding)
names = [str(i) for i in range(1, 1116)]
layout = Layout(
    autosize=False,
    width=800,
    height=800,
    xaxis=dict(
        autorange=True,
        showgrid=False,
        zeroline=False,
        autotick=True,
        showline=True,
        mirror='all'
    ),
    yaxis=dict(
        autorange=True,
        showgrid=False,
        zeroline=False,
        autotick=True,
        showline=True,
        mirror='all'
    )
)
trace1 = Scatter(
    x=Y[:, 0],
    y=Y[:, 1],
    mode='markers',
    text=names,
    textposition='top'
)
fig = Figure(data=[trace1], layout=layout)
iplot(fig)
In [69]:
tsne = manifold.TSNE(n_components=3, init='pca', random_state=0, method='exact', learning_rate=500, verbose=0, early_exaggeration=1)
Y = tsne.fit_transform(store_embedding)
names = [str(i) for i in range(1, 1116)]
layout = Layout(
    autosize=False,
    width=1000,
    height=1000,
)
trace1 = Scatter3d(
    x=Y[:, 0],
    y=Y[:, 1],
    z=Y[:, 2],
    mode='markers',
    text=names,
    marker=dict(
        size=2,
        opacity=0.9
    )
)
fig = Figure(data=[trace1], layout=layout)
iplot(fig)
In [ ]: